<template>
  <div class="order-detail-page" v-if="orderData">
    <!-- 操作栏 -->
    <OrderDetailAction :orderData="orderData"></OrderDetailAction>

    <!-- 步骤条 组件xtx-steps.vue-->
    <DetailsStep :orderData="orderData"></DetailsStep>
    <!-- 物流栏 -->
    <Suspense>
      <DetailLogistics
        :orderData="orderData"
        v-if="[3, 4, 5].includes(orderData.orderState)"
      ></DetailLogistics>
      <template #fallback><div class="loading">loading...</div></template>
    </Suspense>
    <!-- 订单商品信息 -->
    <OrderInfo :orderData="orderData"></OrderInfo>
  </div>
</template>
<script>
import OrderDetailAction from "./components/detail-action.vue";
import { orderDetails } from "@/api/order";
import { useRoute } from "vue-router";
import { ref } from "vue";
import DetailsStep from "./components/detail-step";
import DetailLogistics from "./components/detail-logistics.vue";
import OrderInfo from "./components/detail-information.vue"
export default {
  name: "OrderDetailPage",
  components: {
    OrderDetailAction,
    DetailsStep,
    DetailLogistics,
    OrderInfo
  },
  setup() {
    const route = useRoute();
    const orderData = ref(null);
    console.log(route.params.id);
    orderDetails(route.params.id).then((data) => {
      orderData.value = data.result;
      console.log(orderData);
    });
    return { orderData };
  },
};
</script>
<style scoped lang="less">
.order-detail-page {
  background: #fff;
  .loading{
    height: 50px;
  display: flex;
  align-items: center;
  padding: 0 30px;
  background-color: #f5f5f5;
  margin: 30px 50px 0;
  }
}
</style>